﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Users.SnsConnect;

namespace Users.WebSite.Login
{
	public partial class SnsAuth : PageBase
	{
		protected void Page_Load(object sender, EventArgs e)
		{
			string sns = Request.QueryString["sns"];
			string code = Request.QueryString["code"];
			string error = Request.QueryString["error"];


			if (String.IsNullOrEmpty(sns)) return;
			sns = sns.Trim().ToLower();

			if (String.IsNullOrEmpty(code))
			{
				string authUrl = "";
				switch (sns)
				{
					case "taobao":
						authUrl = Taobao();
						break;
					case "weibo":
						authUrl = Weibo();
						break;
					case "qzone":
						authUrl = Qzone();
						break;
					case "renren":
						authUrl = Renren();
						break;
					default:
						return;
				}

				Response.Redirect(authUrl);
			}
			else
			{

			}
		}

		string Taobao()
		{
			return OAuth2Utils.CreateOAuth2Client(OAuth2Utils.Taobao_OAuth2Params).GetFullAuthUrl();
		}

		string Weibo()
		{
			return OAuth2Utils.CreateOAuth2Client(OAuth2Utils.Weibo_OAuth2Params).GetFullAuthUrl();
		}

		string Qzone()
		{
			return OAuth2Utils.CreateOAuth2Client(OAuth2Utils.Qzone_OAuth2Params).GetFullAuthUrl();
		}

		string Renren()
		{
			return OAuth2Utils.CreateOAuth2Client(OAuth2Utils.Renren_OAuth2Params).GetFullAuthUrl();
		}
	}
}